package com.sys.controller;

import com.sys.common.aop.Operation;
import com.sys.common.constant.Constant;
import com.sys.common.util.ResponseDateUtil;
import com.sys.common.util.ResultBuilder;
import com.sys.pojo.EmployeeAttendance;
import com.sys.service.EmployeeAttendanceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 出勤 前端控制器
 * </p>
 *
 * @author ZJF
 * @since 2021-04-01
 */
@Api(tags = {"员工出勤"})
@RestController
@RequestMapping("/employeeAttendance")
public class EmployeeAttendanceController {
    @Resource
    private EmployeeAttendanceService employeeAttendanceService;

    @PostMapping("/attendances")
    @RequiresPermissions("attendance:list")
    public ResponseDateUtil pageAttendance(@RequestBody EmployeeAttendance vo) {
        return ResultBuilder.success(employeeAttendanceService.pageAttendance(vo));
    }

    @PostMapping("/attendanceAdd")
    @RequiresPermissions("attendance:add")
    @ApiOperation("添加员工出勤")
    @Operation("添加员工出勤")
    public ResponseDateUtil addCategoryt(@RequestBody EmployeeAttendance vo) {
        Boolean aBoolean = employeeAttendanceService.addAttendance(vo);
        if (aBoolean) {
            return ResultBuilder.success();
        } else {
            return ResultBuilder.errorInfo(Constant.ADDFAILED);
        }
    }

    @GetMapping("/getAttendanceInfo")
    @ApiOperation("获取出勤统计信息")
    public ResponseDateUtil getAttendanceInfo(@RequestParam("eid") String eid, @RequestParam("mounth") String mounth) {
        return ResultBuilder.success(employeeAttendanceService.searchInfo(eid, mounth));
    }

}
